Discussion討論區-1 << 
Previous Next >> Manipulating strings a few ways處理字符串幾種方法
User input in Python使用Python的用戶輸入
To get user input in Python (3), the command you use is
 input(). Store the result in a variable, and use it to your heart’s content. Remember that the result you get from the user will be a string, even if they enter a number.
For example,
name = input("Give me your name: ")
print("Your name is " + name)
What this will print in the terminal (or the shell, whatever you are running Python in) will be:
>>> Give me your name: Michele
Your name is Michele
What happens at the end of input() is that it waits for the user to type something and press ENTER. Only after the user presses ENTER does the program continue.
要在Python(3)中獲得用戶輸入,你使用的命令是input()。將結果存儲在變量中,並將其用於你的內心。請記住,即使用戶輸入數字,你從用戶那裡得到的結果也將是字符串。
例如,
name = input("Give me your name: ")
print("Your name is " + name)
這將在終端(或外殼,無論您在其中運行Python的是什麼)中顯示的內容是:
>>> Give me your name: Michele
Your name is Michele
最後發生的input()是,它等待用戶鍵入內容並按Enter。僅在用戶按下ENTER之後,程序才會繼續。
Discussion討論區-1 << 
Previous Next >> Manipulating strings a few ways處理字符串幾種方法